package com.scs.application.consts;

import com.scs.application.core.exception.BusinessException;
import com.scs.application.modules.wm.enums.WorkOrderType;

import java.util.*;

/**
 * @Description： 系统常量
 */
public class GlobalConsts {
    // 后台版本号
    public static final String VERSION_API = "25072003";

    public static final String YES_STR = "1";

    public static final String NO_STR = "0";

    public static final Integer YES = 1;
    public static final Integer NO = 0;

    public static final String TEST = "111";

    public static final String CATEGORY_TOP_NODE = "0";

    //仓库入库
    public static final Integer ORDER_DIRECTION_IN = 1;

    //仓库出库
    public static final Integer ORDER_DIRECTION_OUT = -1;

    // 流程结束节点值
    public static final String FLOW_END_VALUE = "end";

    // 流程审核通过节点值
    public static final String FLOW_PASS_VALUE = "pass";

    // 流程开始节点值
    public static final String FLOW_START_VALUE = "start";

    // 流程提交节点值
    public static final String FLOW_SUBMIT_VALUE = "submit";
    // 流程确认节点值
    public static final String FLOW_CONFIRM_VALUE = "confirm";

    // 流程拣货中节点值
    public static final String FLOW_PICKING_VALUE = "picking";

    // 流程拣货完成节点值
    public static final String FLOW_PICKED_VALUE = "picked";

    // 流程开始作废值
    public static final String FLOW_CLOSE_VALUE = "close";

    /**结算单结算依据字段清单
    */
    public static final List<String> SYSTEM_SETTLEMENT_FIELDS= Arrays.asList("flowStatus","accountCheckStatus");

    /**手动入库最大可输入包装数量
    */
    public static final int MAX_PACKAGE_QTY = 1000;



    /**自动采购
     */
    public static final String APPLYAUTO_REFTYPE_AUTO_PURCHASE = "PURCHASE";
    /**自动配送
    */
    public static final String APPLYAUTO_REFTYPE_AUTO_APPLY = "DIST";

    /**自动请领来源,安全库存
     */
    public static final String AUTO_REF_TABLE_SAFE = "SAFE_STOCK";
    /**自动请领来源,科学请领需求
     */
    public static final String AUTO_REF_TABLE_APPLY = "DEPT_APPLY";

    /**询价单推送状态，对应cfg_parameter，即系统参数配置里面的标识。
     * 当准入审核单状态=该状态时，将推送询价单
     */
    public static final String ADM_PUSH_STATUS = "ADM_PUSH_STATUS";


    /**中标结果推送状态，对应cfg_parameter，即系统参数配置里面的标识。
     * 当准入审核单状态=该状态时，将推送中标结果
     */
    public static final String ADM_BID_PUSH_STATUS = "ADM_PUSH_STATUS";


    /**2.HIS同步调价
     *
     */
    public static final String adjustTypeHIS = "2";
    /**1:HRP同步调价
     */
    public static final String adjustTypeHrp = "1";

    /**1:人工调价
     */
    public static final String adjustTypeManual = "0";

    /**
     * 周期：每天
     */
    public static final String periodEveryDay = "0";
    /**
     * 周期：每月
     */
    public static final String periodEveryMonth = "1";
    /**
     * 周期：每年
     */
    public static final String periodEveryYear = "2";

    /**
     * 请领类型 ：请领
     */
    public static final String applyTypeOfApply = "1";
    /**
     * 请领类型 ：需求
     */
    public static final String applyTypeOfDemand = "2";
    /**
     * 报表日期筛选
     */
    public static final String DATEAREA = "dateArea";
    /**
     * 报表日期年份筛选
     */
    public static final String DATEAREAYEAR = "dateyear";
    /**
     * 报表日期月份筛选
     */
    public static final String DATEAREAMONTH = "datemonth";


    /**
     * ChannelFilter 需要过滤的
     * <pre>使用等于
     *     /tool/uploadImg 那么等于/tool/uploadImg的将被排除
     * </pre>
     */
    public static final List<String> CHANNEL_FILTER_EXCLUDE = Arrays.asList("/tool/uploadMore","/sys/file/uploadMore","/sys/flow_instance/uploadAttachment","/spdsocket", "/user/uploadPicture", "excelImport", "/LMSAms");

    /**
     * svn版本记录 拉取默认起始时间
     */
    public static final String SVNVERSION_BEGIN = "2021-06-01";
    /**
     * svn版本记录 日志分隔符
     */
    public static final String SVNVERSION_LOG_SPLIT = "#分隔符#";

    /**
     * 运营评价--库存周转率
     */
    public static final String APPRAISE_TYPE_ROTATE_RATE = "1";

    /**
     * 运营评价--备货满足率
     */
    public static final String APPRAISE_TYPE_CHOICE_RATE = "2";

    /**
     * 运营评价--采购响应率
     */
    public static final String APPRAISE_TYPE_PURCHASE_RATE = "3";


    public static final String MATR_BASE_TYPE_LOM ="lom";
    /**
     * svn版本记录 日志分隔符
     */
    public static final Map<String,String> MATR_BASE_TYPE_MAP = new HashMap<String,String>(){{
        put("matr","耗材");
        put("reagent","试剂");
        put("drugs","药品");
        put("lom","后勤物资");
        put("device","设备");
        put("part","配件");
        put("package","跟台");
        put("","未知");
    }};

    /**
     * svn版本记录 日志分隔符
     */
    public static final Set<String> MATR_BASE_TYPE_KEYS = MATR_BASE_TYPE_MAP.keySet();


    /**
         * @Description：  定时任务执行状态
     */
    public static class JobStatusExecution{
        /**
         *  not_run：未启动,定时器未启动或者手动关闭了定时器
         */
        public static final String NOT_RUN = "not_run";

        /**
         *  not_exec：定时器已启动，但是该任务尚未执行，即：还没有到达该任务的执行周期
         */
        public static final String NOT_EXEC = "not_exec";

        /**
         * not_exec：定时器已启动，该任务正在执行中，即：到达执行周期后对应业务方法正在处理中
         */
        public static final String EXEC = "exec";

        /**
         *  pause: 暂停:，定时器已启动，该任务已暂停
         */
        public static final String PAUSE = "pause";
    }

    public class DistTransferSourceType{
        /**手动单据 手动创建，主动单据，
         */
        public static final String MANUAL = "manual";

        /**自动科室需求 由二级库配送或调拨需求转换过来的，这种类型单据拣货需要完全按照需求
         */
        public static final String DEPT_APPLY_AUTO = "dept_apply_auto";


        /**手工科室需求 手动创建的科室需求，这种类型单据拣货需要完全按照需求
         */
        public static final String DEPT_APPLY = "dept_apply";
    }


    //盘点类型
    public class CheckType{
        /**所有库存
         */
        public static final String all = "all";

        /**今天库存变动
         */
        public static final String today = "today";


        /**昨天库存变动
         */
        public static final String yesterday = "yesterday";

        /**本周库存变动
         */
        public static final String thisWeek = "thisWeek";
        /**本周库存变动
         */
        public static final String thisMonth = "thisMonth";
        /**上月库存变动
         */
        public static final String lastMonth = "lastMonth";
    }


    //变更类型类型
    public class ChangeType{
        /**耗材单品单位
         */
        public static final String matrSkuUnit = "耗材单品单位";

        /**耗材单品单位
         */
        public static final String matrSkuQty = "耗材单品价格";
    }

    //调拨类型
    public static class TransferType {
        //配送出库
        public static final String distOut = WorkOrderType.OUT_SHIFT;
        //科室退货
        public static final String returnIn = WorkOrderType.IN_DEPT_RETURN;

        public static  List<String> TransferTypeAll;
    }
    static{
        //将WTransferType下面所有String变量追加到 TransferTypeAll中
        TransferType.TransferTypeAll= new ArrayList<String>();
        Arrays.stream(TransferType.class.getDeclaredFields()).filter(fieldFilter -> fieldFilter.getType() == String.class).forEach(field -> {
            String fieldValue;
            try {
                fieldValue = (String) field.get(WorkOrderType.class);
                if (TransferType.TransferTypeAll.contains(fieldValue)) throw new BusinessException("TransferType类型值【%s】重复",fieldValue);
                TransferType.TransferTypeAll.add(fieldValue);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        });
    }

    //结算类型
    public class SettlementType {
        //出库结算
        public static final String outSettlement = "out";

        //用后结算
        public static final String usedSettlement = "used";
    }

    //结算类型
    public static class Spd {
        //期初供应商id
        public static final String supplierNameInit = "期初供应商";

        //单号名称列表
        public static final List<String> busKeyNameList = Arrays.asList("busKey","useKey", "adjustKey", "oprtApplyKey");

        //英文字段列表
        public static final List<String> enFieldList = Arrays.asList("sn","rfid","sn_no","hibc","snno","udi","gtin","sqlid");
    }

    //参数类型
    public class MarkParameterTYpe {
        //数据字典数据
        public static final String DICT_DATA = "dict_data";

        //数据字典类型
        public static final String DICT_TYPE = "dict_type";

        //系统参数
        public static final String PARAMETER = "parameter";

        //打印模板配置
        public static final String PRINT_TEMPLATE = "print_template";

        //用户站内消息
        public static final String USER_MSG = "user_msg";
    }

    //socket消息格式类型
    public class WebSocketMsgType {
        //参数变化
        public static final String PARAM_CHANGE = "param_change";
    }

    //订单收货状态
    public class OrderStatusIn {
        //未入库
        public static final String UN_IN = "0";
        //部分入库
        public static final String PART_IN = "1";
        //全部入库
        public static final String ALL_IN = "2";
    }
    //订单同步状态
    public class OrderSyncStatus {
        //未入库
        public static final String UN_CONFIRM = "0";
        //部分入库
        public static final String UN_DELIVERY = "1";
        //全部入库
        public static final String DELIVERED = "2";
    }

    //特殊符号
    public class SpecialSymbol  {
        //中文逗号
        public static final String COMMA_CN = "，";

        //换行
        public static final String WRAP = "\n";

        //中文逗号回车
        public static final String COMMA_CN_WRAP = "，\n";
    }

    /**
     * ControllerInterceptor 校验 需要过滤的
     */
    public static final List<String> FLOW_CHECK_FILTER_EXCLUDE = Arrays.asList("/user/updateUserState");

    public static  String PO_FROM_TYPE_SCP = "SCP"; //

    //his同步类型
    public class HISSyncType  {
        //数据库视图
        public static final String VIEW = "view";

        // HTTP get请求
        public static final String HTTP_GET = "httpGet";

    }

    public static final String PO_PACKAGE= "package";
}
